package com.example.controller.web;

import com.example.common.Result;
import com.example.dto.ArticlePageDTO;
import com.example.service.ArchiveService;
import com.example.vo.ArchiveVO;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 归档控制器
 */
@Slf4j
@RestController
@RequestMapping("/frontend/archive")
public class ArchiveController {

    @Resource
    private ArchiveService archiveService;

    /**
     * 获取文章归档列表
     */
    @PostMapping("/list")
    public Result<List<ArchiveVO>> list(@RequestBody ArticlePageDTO articlePageDTO) {
        log.info("获取归档列表 - 页码: {}, 每页数量: {}", 
                articlePageDTO.getCurrent(),
                articlePageDTO.getSize());
        
        List<ArchiveVO> archiveList = archiveService.getArchiveList(articlePageDTO);
        
        log.info("归档列表响应 - 归档时间段数量: {}", archiveList.size());
        
        return Result.success(archiveList);
    }
} 